<template>
  <div class="container">
    <div class="btnClose">
      <span class="iconfont iconicon-test"></span>
    </div>

    <div class="logo">
      <span class="iconfont iconnew"></span>
    </div>
    <AuthInput
      errMsg="请输入正确的用户名"
      :rule="/^.{5,11}$/"
      placeholder="请输入用户名"
      type="text"
      @setValue="setUsername"
    />
    <AuthInput
      errMsg="请输入昵称"
      :rule="/^.{3,8}$/"
      placeholder="请输入昵称"
      type="text"
      @setValue="setNickname"
    />
    <AuthInput
      errMsg="请输入正确的密码"
      :rule="/^.\d{3,12}$/"
      placeholder="请输入密码"
      type="password"
      @setValue="setPassword"
    />
    <AuthBtn btnText="马上注册" @click.native="register" />
  </div>
</template>

<script>
import AuthInput from "../components/AuthInput";
import AuthBtn from "../components/AuthBtn";
export default {
  components: {
    AuthInput,
    AuthBtn
  },
  data(){
    return{
     setusername:'',
     setnickname:'',
     setpassword:'',
    }
  },
  methods:{
    setUsername(newValue){
      this.username = newValue;
    },
    setNickname(newValue){
      this.nickname = newValue;
    },
    setPassword(newValue){
      this.password = newValue;
    },
    register(){
      this.$axios({
        method:'post',
        url:"/register",
        data:{
          username:this.username,
          nickname:this.nickname,
          password:this.password,
        }
      }).then((res)=>{
        console.log(res.data);
        if(res.data.message == "注册成功"){
          this.$toast.success('注册成功');
        }
      })
    }
  }
  
};
</script>

<style lang="less" scoped>
.container {
  padding: 20/360 * 100vw;
}
.iconicon-test {
  width: 27/360 * 100vw;
  height: 27/360 * 100vw;
}
.logo {
  text-align: center;
  .iconnew {
    font-size: 127/360 * 100vw;
    color: skyblue;
  }
}
</style>